<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的第一个文件</title>
    <style>
        div{
            width: 100%;
            height: 300px;
            background-color: red;
            border: 1px solid red;
            border-radius: 10px;
        }
    </style>
</head>
<body>
    <div>我是王旭</div>
</body>

<script>
    var div =document.querySelector('div')

    div.onclick =function(){
        div.style.backgroundColor = 'blue'
    }
</script>
</html>